package com.yidu.t299.dao.ljc;
import com.yidu.t299.domain.ljc.Outstockcopy;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/8 10:19
 */
@Mapper
public interface OutstockcopyMapper {
    /**
     * 增加
     * @param record
     * @return
     */
    @Insert({
            "insert into out_stock_copy (out_stock_id,textbook_name, author,publishing_company,textbook_num,collecting,out_stock_date,handled)" +
                    " values " +
                    "(#{outId,jdbcType=INTEGER}, #{textbookName,jdbcType=VARCHAR},#{author,jdbcType=VARCHAR}," +
                    "#{publishingCompany,jdbcType=VARCHAR},#{textbookNum,jdbcType=INTEGER}," +
                    "#{collecting,jdbcType=VARCHAR},#{outStock,jdbcType=VARCHAR}," +
                    "#{handled,jdbcType=VARCHAR})"
    })
    int insert(Outstockcopy record);

    /**
     * 删除
     * @param outId
     * @return
     */
    @Delete({
            "delete from out_stock_copy" +
                    " where out_stock_id = #{outId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer outId);

    /**
     * 修改
     * @param record
     * @return
     */
    @Update({
            "update out_stock_copy" +
            " set textbook_name = #{textbookName,jdbcType=VARCHAR},"+
                    "author = #{author,jdbcType=VARCHAR},"+
                    "publishing_company = #{publishingCompany,jdbcType=VARCHAR},"+
                    "textbook_num = #{textbookNum,jdbcType=INTEGER},"+
                    "collecting = #{collecting,jdbcType=VARCHAR},"+
                    "out_stock_date = #{outStock,jdbcType=VARCHAR},"+
                    "handled = #{handled,jdbcType=VARCHAR}"+
                    "where out_stock_id = #{outId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Outstockcopy record);

    /**
     * 根据编号查询信息
     * @param outId
     * @return
     */
    @Select({
            "select" +
                    " out_stock_id,textbook_name, author,publishing_company,textbook_num,collecting,out_stock_date,handled" +
                    " from out_stock_copy" +
                    " where out_stock_copy = #{outId,jdbcType=INTEGER}"
    })
    @Results(id = "OutstockcopyMap",value = {
            @Result(id = true,column = "out_stock_id",property = "outId"),
            @Result(column = "textbook_name",property = "textbookName"),
            @Result(column = "author",property = "author"),
            @Result(column = "publishing_company",property = "publishingCompany"),
            @Result(column = "textbook_num",property = "textbookNum"),
            @Result(column = "collecting",property = "collecting"),
            @Result(column = "out_stock_date",property = "outStock"),
            @Result(column = "handled",property = "handled")

    })
    Outstockcopy selectByPrimaryKey(Integer outId);

    /**
     * 分页查询数据信息
     * @param rows
     * @param page
     * @param condition
     * @return
     */
    @Select("select * from out_stock_copy where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("OutstockcopyMap")
    List<Outstockcopy> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 条件查询数据
     * @param condition
     * @return
     */
    @Select("select count(*) from out_stock_copy where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);

}
